import Vue from 'vue'
import Router from 'vue-router'


Vue.use(Router)

const router = new Router({
  routes: [

   {path: '/login',name: 'login',component : ()=>import("@/views/Login"),hidden:false,meta:{noAuth:true} },
    {
      path:'/',
      name: 'home' ,
      component : ()=> import("@/views/Home"),
      hidden : false,
      redirect:'/index',
      children:[
        {
          path:'index',
          name:'导航页',
          component:()=>import('@/views/Index')
        },

        {
          path:'manager',
          name: '测试',
          redirect:'/manager/manager',
          icon:'document',//manager
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children:[
         {path:'schedule',name:'需求计划',icon:'schedule',component:()=>import('@/views/TestManager/Schedule'),hidden:false},
            // {path:'bug',name:'BUG',icon:"bug",component:()=>import('@/views/TestManager/Bug')},
            {path:'testnav',name:'测试导航',icon:"nav",component:()=>import('@/views/TestManager/QANavPage')},
            {path:'study',name:"学习资料",icon:"study",component:()=>import("@/views/TestManager/Study")},
            {path:'manager',name:"项目管理",icon:"manager",component:()=>import("@/views/TestManager/Manager")},
          ],
        },
        //{path:'/schedule',name:'需求计划',icon:'schedule',component:()=>import('@/views/TestManager/Schedule')},
        {
          path:'shuiyoutools',
          name:'税友小工具',
          icon:'setting',
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children:[
            {path:'xmlParse', name:'增值服务xml更改',icon:'schedule', component:()=>import('@/views/shuiyoutools/xmlParse')},
            {path:'xmlParseUpload', name:'增值服务xml更改test',icon:'schedule', component:()=>import('@/views/shuiyoutools/xmlParseUpload')},
            {path:'szjkzip', name:'事中监控指标测试云端',icon:'schedule', component:()=>import('@/views/shuiyoutools/szjkzip')},
            {path:'szjkzipnew', name:'事中监控指标测试局端',icon:'schedule', component:()=>import('@/views/shuiyoutools/szjkzipnew')},
            {path:'config', name:'配置',icon:'setting', component:()=>import('@/views/shuiyoutools/config')}
          ]
        },
        {
          path:'sycompare',
          name:'数值比对',
          icon:'setting',
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children:[
            // {path:'project', name:'项目',icon:'schedule', component:()=>import('@/views/sycompare/project')},
            {path:'project', name:'目录',icon:'schedule', component:()=>import('@/views/sycompare/projects')},
            {path:'script', name:'用例管理',icon:'schedule', component:()=>import('@/views/sycompare/scripts')},
            {path:'tasks', name:'任务管理',icon:'schedule', component:()=>import('@/views/sycompare/tasks')},

            {path:'result', name:'结果管理',icon:'setting', component:()=>import('@/views/sycompare/result')},
            {path:'dbmanage', name:'数据库管理',icon:'schedule', component:()=>import('@/views/sycompare/dbmanage')},
          ]
        },
        {
          path:'etltest',
          name:'etl标准作业测试',
          icon:'setting',
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children:[
            // {path:'project', name:'项目',icon:'schedule', component:()=>import('@/views/sycompare/project')},
            {path:'oracleinfo', name:'数据库链接',icon:'schedule', component:()=>import('@/views/etlAndDbStructeCompare/OracleInfo')},
            {path:'etltest', name:'etl测试',icon:'schedule', component:()=>import('@/views/etlAndDbStructeCompare/etl_test')},
            {path:'bjgtest', name:'表结构对比',icon:'schedule', component:()=>import('@/views/etlAndDbStructeCompare/bjg_test')},


          ]
        },

     /*   {
          path:'tools',
          name:'小工具',
          icon:'setting',
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children:[
            {path:'dbconfig',name:'环境配置',icon:'schedule',component:()=>import('@/views/Tools/dbconfig'),hidden:false},
            {path:'sqldata',name:'sqlCase',icon:'sqlcase',component:()=>import('@/views/Tools/SqlDataProvider')},
            {path:'cardprovide',name:'cardprovide',icon:'cardprovide',component:()=>import('@/views/Tools/CardProvide')},
          ],
        },*/
       /* {
          path:'interface',
          name:'接口测试',
          redirect:"interface/result",
          icon:'sort',
          component:{render (c) { return c('router-view') }},
          meta:{isbar:true},
          children: [
            {path:'interfaceManager',name:'接口管理',icon:'intermanager',component:()=>import("@/views/InterfaceTest/InterfaceManager")},
            {path:'testCase',name:'用例管理',icon:'casemanager',component:()=>import("@/views/InterfaceTest/TestCase")},
            {path:'result',name:'测试结果',icon:'result',component:()=>import("@/views/InterfaceTest/ResultCollect")}
          ]
        },*/
       /* {
          path:'uitest',
          name:'UI测试',
          icon:'menu',
          component:()=>import("@/views/UITest/UITest"),
        },*/
        {
          path:'uitest',
          name:'UI测试',
          icon:'menu',
          meta:{
           // requireAuth:true
          },
          component:()=>import("@/views/UITest/UITest"),
        },
        {
          path:'practise',
          name:'接口练习',
          icon:'menu',
          meta:{
           // requireAuth:true
          },
          component:()=>import("@/views/practise/Practise"),
        },
      /*  {
          path:'performancet',
          name:'性能测试',
          icon:'loading',
          component:()=>import("@/views/PerformanceTest/PerformanceTest")
        },*/
       /* {path:'managerdetail/:id',name:"managerdetail",icon:"manager",component:()=>import("@/views/TestManager/managerChildren/IterationDetail")},*/
      ]

    },

  ],
  scrollBehavior: () => ({ y: 0 }),mode: 'hash',
  linkActiveClass: 'open active',
})

router.beforeEach((to,from,next)=>{
  if (to.matched.some(res=>res.meta.noAuth)){
     next()
  }else{
    if (localStorage.getItem('token')){
      next()
    }else{
      next({
        path:'/login',
        query: {redirect: to.fullPath}
      })
    }
  }

})




export default router
